def main():
   
    sl = []    
    while True :
        str = raw_input();
        if str == "" :
            break
        
        parts = str.split(" ")
        unit = parts.pop(0)
        details = set(parts)
        sl.append( [unit, details] )
        
    for s1 in sl :       
        for s2 in sl :
            if s1[0] in s2[1] :
                s2[1].difference_update([s1[0]])
                s2[1].update(s1[1])
        
    if len(sl[0][1]) == 0 :
        print "YES"
    else :
        print "NO"
        
main()